home *** CD-ROM | disk | FTP | other *** search
/ Boot Disc 5 / boot-disc-1997-01.iso / media / utility.cst / 00028_Script_Scripting Utilities < prev    next >
Text File  |  1996-11-05  |  4KB  |  129 lines

  1. on document myscript
  2.   set q=quote
  3.   set rt=return
  4.   set buffer=rt
  5.   if the number of member myscript<1 then
  6.     alert "An attempt was made to document a non-existent script."
  7.     exit
  8.   else
  9.     if the type of member myscript<>#script then
  10.       alert "An attempt was made to document a non-script object."
  11.       exit
  12.     end if
  13.   end if
  14.   set curtext=the scripttext of member myscript
  15.   set startline=0
  16.   set endline=0
  17.   repeat with index=1 to the number of lines in curtext
  18.     if line index of curtext="on help me" then
  19.       set startline=index
  20.     end if
  21.     if line index of curtext="end help" then
  22.       set endline=index
  23.     end if
  24.   end repeat
  25.   if startline>0 then
  26.     delete line startline to endline of curtext
  27.   end if
  28.   set olddelimiter=the itemdelimiter
  29.   set the itemdelimiter=quote
  30.   repeat with index=1 to the number of lines in curtext
  31.     set curline=line index of curtext
  32.     if offset("--#",curline) then
  33.       set newstr=(char 4 to length(curline) of curline)
  34.       set itemlist=[]
  35.       repeat with curitem=1 to the number of items in curline
  36.         add itemlist,item curitem of newstr
  37.       end repeat
  38.       set midbuffer=""
  39.       repeat with curitem=1 to count(itemlist)
  40.         if curitem<count(itemlist) then
  41.           set midbuffer=midbuffer&(getat(itemlist,curitem))&q&""e&"&q
  42.         else
  43.           set midbuffer=midbuffer&(getat(itemlist,curitem))
  44.         end if
  45.       end repeat
  46.       set buffer=buffer&"   put "&q&midbuffer&q&rt
  47.     end if
  48.   end repeat
  49.   set curtext=curtext&rt&rt&"on help me"&rt
  50.   set curtext=curtext&buffer
  51.   set curtext=curtext&"end help"
  52.   set the scripttext of member myscript to curtext
  53.   set the itemdelimiter=olddelimiter
  54.   put q&myscript&q&"script successful processed."
  55. end
  56.  
  57. on man myscript,commentflag
  58.   set buffer=""
  59.   set curtext=the scripttext of member myscript
  60.   repeat with index=1 to the number of lines in curtext
  61.     set curline=line index of curtext
  62.     set word1=word 1 of curline
  63.     case word1 of 
  64.       "on","property":
  65.         put curline
  66.       "--#":
  67.         if commentflag then
  68.           put "*"&(char 4 to length(curline) of curline)
  69.         end if
  70.     end case
  71.   end repeat
  72. end
  73.  
  74. on default defvalue,passedvalue
  75.   if voidP(passedvalue) then
  76.     set curval=defvalue
  77.   else
  78.     set curval=passedvalue
  79.   end if
  80.   return curval
  81. end
  82.  
  83. on echoname srcstart,srcend,targetstart
  84.   repeat with index=srcstart to srcend
  85.     set newcast=targetstart+index-srcstart
  86.     set the name of member newcast to the name of member index
  87.   end repeat
  88. end
  89.  
  90. on getdrive
  91.   set curpath=the moviepath
  92.   set olddelimiter=the itemdelimiter
  93.   set the itemdelimiter="\"
  94.   set drive=(item 1 of curpath)&"\"
  95.   set the itemdelimiter=olddelimiter
  96.   return drive
  97. end
  98.  
  99. on querybrowser
  100.   global gbrowser
  101.   if the platform="Windows,32" then
  102.     set browserlist=["Progra~1\Netscape\Naviga~1\Program\Netscape.exe","progra~1\Micros~1\iexplore.exe"]
  103.   else
  104.     set browserlist=["netscape\naviga~1\netscape.exe"]
  105.   end if
  106.   openxlib getdrive()&"misc_x.dll"
  107.   set obj=misc_x(mNew)
  108.   set browserfound=false
  109.   repeat with browser in browserlist
  110.     if obj(mFileExists,"c:\"&browser)=1 then
  111.       set browserfound=true
  112.       set gbrowser="c:\"&browser
  113.       exit repeat
  114.     end if
  115.   end repeat
  116.   if not browserfound then
  117.     if gbrowser<>#none then
  118.       set status=obj(mAsk, "Can't find a browser.  Can you help me?","c:\","Okay","Cancel")
  119.       if status<>"Don't select browser right now." then
  120.         set gbrowser=status
  121.       else 
  122.         set gbrowser=#none
  123.       end if
  124.     end if
  125.   end if
  126.   obj(mDispose)
  127.   return gbrowser
  128. end
  129.